package com.sir.tao.carhire.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author dyy
 * @data 2021/12/6 10:59
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {

    private String code;
    private String message;
    private T data;

    public static CommonResult<Object> fail(String message){
        return commonResult(CommonConstant.FAIL_CODE,message);
    }

    public static CommonResult<Object> commonResult(String code,String message){
        CommonResult<Object> commonResult = new CommonResult<>();
        commonResult.setCode(code);
        commonResult.setMessage(message);
        return commonResult;
    }

    public static  CommonResult<Object> success(){
        return commonResult(CommonConstant.SUCCESS_CODE,CommonConstant.SUCCESS_MESSAGE);
    }

    public static  CommonResult<Object> success(Object data){
        return new CommonResult<>(CommonConstant.SUCCESS_CODE, CommonConstant.SUCCESS_MESSAGE, data);
    }


}
